package com.neu.niuyuchao.servlet;

import com.neu.niuyuchao.service.StuInfoService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@WebServlet(name = "StuApplyServlet", urlPatterns = {"/StuApplyServlet.do"})
public class StuApplyServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     request.setCharacterEncoding("utf-8");
        Map<String,String[]> params=request.getParameterMap();
        StuInfoService stu=new StuInfoService();
        boolean flag=stu.doCommitApply(params);
//        System.out.println(flag);
        if(flag){
            response.sendRedirect(request.getContextPath()+"/commons/success.jsp");
        }else{
            response.sendRedirect(request.getContextPath()+"/commons/fail.jsp");
        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
